-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access blocks and transactions of the chain with lock #583
Conversation
Libplanet/Blockchain/BlockChain.cs
Outdated
/// </param> | ||
/// <exception cref="KeyNotFoundException">Thrown when there is no | ||
/// <see cref="Transaction{T}"/> with a given <paramref name="txId"/>.</exception> | ||
public Transaction<T> this[TxId txId] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of overloading this and making indexer able to return two distinct types, how about declare a method like GetTransaction(TxId)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be better. Fixed.
Codecov Report
@@ Coverage Diff @@
## master #583 +/- ##
==========================================
- Coverage 90.74% 90.72% -0.02%
==========================================
Files 202 202
Lines 15514 15542 +28
==========================================
+ Hits 14078 14101 +23
- Misses 1144 1149 +5
Partials 292 292
|
I think that we also need to add a mutex for block synchronization to |
Co-Authored-By: Hong Minhee <hong.minhee@gmail.com>
#409 occurs when a task tries to read a block or transaction from
BlockChain<T>.Blocks
orBlockChain<T>.Transactions
while another task is writing it. This fixes #409 by changing blocks and transactions in theBlockChain<T>
so that it cannot be accessed without the lock from the outside of the chain.